<?php
namespace App\Logic\ZiNiao\Api;

use App\Libs\ZiNiao\RequireAppToken;
use App\Libs\ZiNiao\RequireOpenClient;
use App\Libs\ZiNiao\RPARequest\PlansDriversOffRequest;
use Exception;
class PlansDriversOff
{
    /**
     * 停用计划
     * 请求方法非Get并且请求参数为Query非Body时使用setParamsContent()其它情况均为setBizContent()
     * @param array $paramsContent ['planIds' => "1271,1655272611,1655272942"]
     * @return mixed
     */
    public function exe($paramsContent = [])
    {
        $openClient = RequireOpenClient::getInstance();
        $requireAppToken = new RequireAppToken();
        $appAuthToken = $requireAppToken->getAppToken($openClient);
        $request = new PlansDriversOffRequest();
        $request->setParamsContent(json_encode($paramsContent));
        $result = $openClient->executeAppToken($request,$appAuthToken);// 发送请求
        $result_decode = json_decode($result);
        if (($result_decode->code === 0 or $result_decode->code === '0') and !isset($result_decode->sub_code)) {
            return $result_decode->data;
        }else {
            report(new Exception('PlansDriversOff失败:' . $result,224));
            die(0);
        }
    }
}
